//
//  MyCategory .m
//  MoneyLog
//
//  Created by wicresoft on 5/18/11.
//  Copyright 2011 wicresoft. All rights reserved.
//

#import "MyCategory.h"

@implementation NSDate (FormatString)

- (NSString*)stringWithFormat:(NSString*)formatter {
    static NSDateFormatter *dateFormatter;
    
    if (dateFormatter == nil) {
        dateFormatter = [[NSDateFormatter alloc] init];
    }
    
    if (formatter == nil || [formatter isEqualToString:@""]) {
        formatter = @"HH:mm:ss";
    }
    
    [dateFormatter setDateFormat:formatter];
    
    return [dateFormatter stringFromDate:self];
}

+ (NSDate *)dateFromString:(NSString*)dateString withFormat:(NSString*)formatter {
    
    static NSDateFormatter *dateFormatter;
    
    if (dateFormatter == nil) {
        dateFormatter = [[NSDateFormatter alloc] init];
    }
    
    if (formatter == nil || [formatter isEqualToString:@""]) {
        formatter = @"HH:mm:ss";
    }
    
    [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
    [dateFormatter setAMSymbol:@"AM"];
    [dateFormatter setPMSymbol:@"PM"];
    //[formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
    
    [dateFormatter setDateFormat:formatter];
    
    return [dateFormatter dateFromString:dateString];
}

@end

@implementation UIImage (FromURLImage)

+(UIImage*) imageFromURLString:(NSString*) urlString
{
    return [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]];
    
}

@end